package com.smallkingson.ylib.view.adapter;

import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

public abstract class YPagerAdapter extends PagerAdapter {

	protected ViewPager pager;

	public YPagerAdapter(ViewPager pager) {

		this.pager = pager;
	}

	private YPagerAdapter() {

	}
	@Override
	public Object instantiateItem(View container, int position) {
 
		View pager = getView(position);

		YPagerAdapter.this.pager.addView(pager);

		return pager;

	}

	public abstract View getView(int position);

	@Override
	public void destroyItem(View container, int position, Object object) {

		YPagerAdapter.this.pager.removeView(getView(position));
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {

		return arg0 == arg1;
	}

	public abstract int getCount();

}